package com.bw.hongye.building.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
public class Contextcontroller {

     @Autowired
     private com.bw.hongye.building.service.contextServer contextServer;

     @GetMapping("/parse}")
     public boolean parse() throws Exception {
         return contextServer.parseContext();
     }

    @GetMapping("/search/{keyword}/{pageNo}/{pageSize}")
      public List<Map<String,Object>> search(@PathVariable String keyword, @PathVariable int pageNo, @PathVariable int pageSize) throws Exception {
        return contextServer.searchPage(keyword,pageNo,pageSize);
      }

      @GetMapping("/search2/{keyword}/{pageNo}/{pageSize}")
     public List<Map<String,Object>> search2(@PathVariable String keyword,@PathVariable int pageNo,@PathVariable int pageSize) throws Exception {
         return contextServer.searchPagehighligh(keyword,pageNo,pageSize);
     }


    @GetMapping("/search3")
    public List search3(
            @RequestParam(value = "keyword",defaultValue = "") String keyword,
            @RequestParam(value = "page",defaultValue = "0") int page,
            @RequestParam(value = "size",defaultValue = "10") int size
    ) throws Exception {
        return contextServer.searchPageHighlightBuilder(keyword, page, size);
    }

}